//------------------------------------------------------------------------------
//	file mm_err.c
//	brief
//		Implementation file for mm error string library.
//
//	$Id: mm_err.c 278 2014-04-18 17:43:00Z ac.verbeck@gmail.com $
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------
//	Copyright and Disclaimer Notice
//
//	Copyright (c) 2014 A.C. Verbeck
//
//	This file is part of winMIDI: windows MIDI -- a direct MIDI interface
//
//	winMIDI is free software: you can redistribute it and/or modify
//	it under the terms of the GNU General Public License as published by
//	the Free Software Foundation, either version 3 of the License, or
//	(at your option) any later version.
//
//	winMIDI is distributed in the hope that it will be useful,
//	but WITHOUT ANY WARRANTY; without even the implied warranty of
//	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//	GNU General Public License for more details.
//
//	You should have received a copy of the GNU General Public License
//	along with winMIDI. If not, see <http://www.gnu.org/licenses/>.
//
//------------------------------------------------------------------------------

#include <stdint.h>																//	Standard int types
#include <stdbool.h>															//	Bool

#include <windows.h>
#include <mmsystem.h>

#include "mm_err.h"

static MM_ERROR_STR mm_err_str[] = {
	{	MMSYSERR_NOERROR,		"No error"				},
	{	MMSYSERR_ERROR,			"Unknown error"			},
	{	MMSYSERR_BADDEVICEID,	"Bad device"			},
	{	MMSYSERR_NOTENABLED,	"Not enabled"			},
	{	MMSYSERR_ALLOCATED,		"Already allocated"		},
	{	MMSYSERR_INVALHANDLE,	"Invalid handle"		},
	{	MMSYSERR_NODRIVER,		"No driver"				},
	{	MMSYSERR_NOMEM,			"No memory available"	},
	{	MMSYSERR_NOTSUPPORTED,	"Not supported"			},
	{	MMSYSERR_BADERRNUM,		"Bad error number"		},
	{	MMSYSERR_INVALFLAG,		"Invalid flag"			},
	{	MMSYSERR_INVALPARAM,	"Invalid parameter"		},
	{	MMSYSERR_HANDLEBUSY,	"Handle is busy"		},
	{	MMSYSERR_INVALIDALIAS,	"Invalid alias"			},
	{	MMSYSERR_BADDB,			"Bad DB"				},
	{	MMSYSERR_KEYNOTFOUND,	"Key not found"			},
	{	MMSYSERR_READERROR,		"Read error"			},
	{	MMSYSERR_WRITEERROR,	"Write error"			},
	{	MMSYSERR_DELETEERROR,	"Delete error"			},
	{	MMSYSERR_VALNOTFOUND,	"Value not found"		},
	{	MMSYSERR_NODRIVERCB,	"No driver CB"			},
	{	WAVERR_BADFORMAT,		"Bad format"			},
	{	WAVERR_STILLPLAYING,	"Still playing"			},
	{	WAVERR_UNPREPARED,		"Buffer unprepared"		}
};
#define	MM_ERR_CT	(sizeof(mm_err_str)/sizeof(MM_ERROR_STR))

char*	getMMErrString(uint16_t id)
{
	uint16_t	idx=0;
	char*		rStr = "Undefined";

	for (idx=0; idx<MM_ERR_CT; idx++) {
		if (mm_err_str[idx].id == id) {
			rStr = mm_err_str[idx].str;
			break;
		}
	}
	return rStr;
}


//
//	End: mm_err.c
//
